﻿import QtQuick 2.0
import QtQuick.Controls 1.3
import QtQuick.Controls.Styles 1.3
import QtQuick.Layouts 1.1

Rectangle {
    id:cyberThreatWidgetLegend
    width:600
    height:100
    color:Qt.rgba(0,0,0,0.5)
    radius: 3

    Row{
        //anchors.centerIn: cyberThreatWidgetLegend
        id:cyberThreatWidgetLegendButton
        spacing: 20

        Repeater {
            model: 5
            Rectangle {
                width: 100
                height: 50
                id: positionerRow
                color:Qt.rgba(0.5,0.5,0.5,0.2)
                border.color: Qt.rgba(0.5,0.5,0.5,0.3)
                border.width: 1
                radius: 3

                Text{
                    id:cyberThreatWidgetTypeTextRow
                    color: getTypeColor()
                    text:getTypeText()
                    font.pixelSize: 24
                    anchors.centerIn: parent
                    function getTypeText() {
                        if (index === 0)
                            return "WAV"
                        else if (index === 1)
                            return "ODS"
                        else if (index === 2)
                            return "OAS"
                        else if (index === 3)
                            return "IDS"
                        else if (index === 4)
                            return "VUL"
                    }
                    function getTypeColor() {
                        if (index === 0)
                            return Qt.rgba(228/255.0,28/255.0,28/255.0,1)
                        else if (index === 1)
                            return Qt.rgba(255/255.0,255/255.0,0/255.0,1)
                        else if (index === 2)
                            return Qt.rgba(128/255.0,255/255.0,0/255.0,1)
                        else if (index === 3)
                            return Qt.rgba(255/255.0,128/255.0,255/255.0,1)
                        else if (index === 4)
                            return Qt.rgba(128/255.0,255/255.0,255/255.0,1)
                    }

                    MouseArea {
                        anchors.fill: parent
                        hoverEnabled: true
                        onEntered: {
                            cursorShape = Qt.PointingHandCursor
                        }
                        onExited: {
                            cursorShape = Qt.ArrowCursor
                        }
                        onClicked: {
//                            app.slotCloseWindMap();
                            app.slotSetCyberThreatType(index);
//                            windControler.visible = false
                        }
                    }
                }
            }
        }
    }

    Row {
        width: 260
        height: 40
        spacing: 20
        id:cyberThreatWidgetCity
        anchors.top: cyberThreatWidgetLegendButton.bottom
        anchors.topMargin: 10
        Text{
            color: "white";
            text:"城市:"
            font.pixelSize: 24
        }
        Item{
            width: 200
            height: 35
            ComboBox {
                id:cyberThreatCCombobox
                anchors.fill: parent
                model: ["Tokyo","Beijing", "Taipei", "Shanghai"]
            }
        }
        Rectangle {
            width: 70
            height: 35
            color: Qt.rgba(0.5,0.5,0.5,0.5)
            radius: 3
            Text{
                anchors.centerIn: parent
                text:"确定"
                font.pixelSize: 24
                color: "white"
            }
            MouseArea {
                anchors.fill: parent
                onEntered: {
                    cursorShape = Qt.PointingHandCursor
                }
                onExited: {
                    cursorShape = Qt.ArrowCursor
                }
                onClicked: {
                    var str = cyberThreatCCombobox.currentText;
                    app.slotSetCyberThreatFilter("city:"+str);
                }

            }
        }

        Rectangle {
            width: 70
            height: 35
            color: Qt.rgba(0.5,0.5,0.5,0.5)
            radius: 3
            Text{
                anchors.centerIn: parent
                text:"清除"
                font.pixelSize: 24
                color: "white"
            }
            MouseArea {
                anchors.fill: parent
                onEntered: {
                    cursorShape = Qt.PointingHandCursor
                }
                onExited: {
                    cursorShape = Qt.ArrowCursor
                }
                onClicked: {
                    var str = cyberThreatCCombobox.currentText;
                    app.slotSetCyberThreatFilter("");
                }

            }
        }


    }

}
